home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: Process_AutoFX.ieb 1.05, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 25/1 1997 Stockholm/Sweden ** ** Accesses ImageFX's AutoFX arexx scripts (.ifx) through any of IE batch ** system's executers. Requires the commercial software package ** ImageFX 2.0 or later. ImageFX is Copyright © by Nova Design. ** */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: if ~show('P','IMAGEFX.1') then do /* check for arexx port */ if ~exists('ImageFX:ImageFX') then do /* check for executable */ 'REQUEST' '"Could not locate ImageFX !"' '" OK "' return '<ERROR>' end else do address 'COMMAND' 'run >NIL: ImageFX:ImageFX' /* run ImageFX */ address 'COMMAND' 'waitforport IMAGEFX.1' /* wait for port */ if RC~=0 then do 'REQUEST' '"Could not locate ImageFXs arexx port!'d2c(10)||, 'Attempt to run ImageFX failed!"' '" OK "' return '<ERROR>' end end end back = 'OK F' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' if command ~= '' then parse var command '#'ifx_file nil 'IE_TO_FRONT' /* Unchanged config, only picked for first image */ if command = '' then do 'GET_FILE' '"Select an ImageFX AutoFX script."' '" OK "' '"ImageFX:Rexx/AutoFX/"' if (RC=5) then return '<ERROR>' ifx_file = strip(result,B,'"') if upper(right(ifx_file,4)) = '.PRE' then ifx_file = get_base(ifx_file) end /* Run AutoFX ifx .pre script */ if exists(ifx_file'.pre') then do address 'IMAGEFX.1' 'ScreenToFront' signal off error address 'IMAGEFX.1' 'RX' ifx_file'.pre' '1' signal on error if RC~=0 then do 'IE_TO_FRONT' return '<ERROR>' end /* Scan AutoFX pre script for SETCLIPs */ str_name = '' ; str_val = '' if open('ifx',ifx_file'.pre','R') then do until eof('ifx') ifx_line = readln('ifx') if compress(upper(left(ifx_line,7))) = 'BASE=' then interpret ifx_line ifx_offset = index(upper(ifx_line),'CALL SETCLIP(') if ifx_offset ~= 0 then do parse var ifx_line nil '('sub_name',' nil ifx_offset = index(upper(sub_name),'ARG(1)') if ifx_offset ~= 0 then do sub_name = delstr(sub_name,ifx_offset,6) sub_name = insert('1',sub_name,ifx_offset-1) end interpret 'sub_name = ' sub_name str_name = str_name||strip(sub_name)'&' sub_val = translate(strip(getclip(sub_name)),'º',' ') if ~datatype(compress(sub_val,'-'),'N') then str_val = str_val '#'sub_val '#&' else str_val = str_val sub_val '#&' end end else return '<ERROR>' nil = close('ifx') 'IE_TO_FRONT' end /* pre script scanning */ else do 'REQUEST' '"This AutoFX script does not have any settings."' '" OK "' str_name = 'dummy_clip&' str_val = '#Gummi-anka' end back = '#'ifx_file '#'str_name str_val return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'frame':'num_frames'"' parse var options '#'ifx_file '#'str_name str_val do until str_name = '' parse var str_name sub_name'&'str_name if strip(sub_name) = '' then leave new_val = '' do until sub_val = '&' parse var str_val sub_val str_val sub_val = compress(sub_val,'#') if sub_val = '&' then leave new_val = new_val sub_val if strip(str_val) = '' then leave end nil = setclip(sub_name,translate(strip(new_val),' ','º')) end ifx_file = strip(ifx_file) address 'IMAGEFX.1' LoadBuffer Force '"'src_image'"' if exists(ifx_file) then do if frame = 1 then address 'IMAGEFX.1' 'ScreenToFront' address 'IMAGEFX.1' 'RX' ifx_file frame '-' '-' '1' num_frames end else do 'REQUEST' '"Could not locate AutoFX script!'d2c(10)ifx_file'"' '" OK "' return '<ERROR>' end address 'IMAGEFX.1' SaveBufferAs ILBM '"'dst_image'"' back = 'OK' return back /* Internal procedures ---------------------------------------------- */ get_base: parse arg get_base_in if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1) else get_base_back = get_base_in return get_base_back /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'